package jcl;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * @author yuisama
 * @date 2022/05/25 19:16
 **/
public class Test {
    public static void main(String[] args) {
//        Student stu1 = new Student("显平",18);
//        Student stu2 = new Student("益州",18);
//        Student stu3 = new Student("显平",19);
//        Map<Student,String> map = new HashMap<>();
//        map.put(stu1,"111");
//        map.put(stu2,"222");
//        map.put(stu3,"333");
//        System.out.println(map);
        Map<Student,String> map = new HashMap<>(6);
        map.put(new Student("显平",18),"111");
//        int n = 16;
//        System.out.println(17 & (n - 1));
//        System.out.println(17 % 16);
//        System.out.println(34 % 16);
//        System.out.println(34 & (n - 1));
    }
}

class Student {
    private String name;
    private int age;

    @Override
    public int hashCode() {
        return Objects.hash(name, age);
    }

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj instanceof Student) {
            Student stu = (Student) obj;
            return this.age == stu.age && this.name.equals(stu.name);
        }
        return false;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}